<div ng-controller="scoreShopCtrl">
    <style>
        table{
            font-size: 14px;
        }
        table th{
            text-align: center;
        }
        table td{
            height: 50px;
            line-height: 50px !important;
            text-align: center;
        }
        table img{
            height: 48px;
            border: none;
        }
        .goods-search{
            margin-left: 25px;
        }
    </style>
    <div>
        <br>
        <a ng-click="addGoods()" class="btn-primary btn-sm nodecoration">添加商品</a>  <span class = "goods-search">商品名称：<input type="text" id = "goods_search"> <a class="btn-primary btn-sm" ng-click="searchGoods()">搜索</a></span>
        <br>
        <br>

        <paging>
            <ul class="pagination" num-pages="tasks.pageCount" current-page="tasks.currentPage"
                on-select-page="selectPage(page)">
                <li ng-class="{disabled: noPrevious()}"><a href="javascript:;" ng-click="selectPrevious()">&laquo;</a>

                </li>
                <li ng-repeat="page in pages" ng-class="{active: isActive(page)}"><a
                        ng-click="selectPage(page)">{{page}}</a>

                </li>
                <li ng-class="{disabled: noNext()}"><a ng-click="selectNext()">&raquo;</a>

                </li>
                <li ng-show="currentPage>6"><a ng-click="selectPage(1)">首页</a>

                </li>
            </ul>
        </paging>
        <table class="table table-condensed" width="647">
            <thead>
            <tr>
                <th>商品id</th>
                <th>商品名称</th>
                <th>商品描述</th>
                <th>创建时间</th>
                <th>库存</th>
                <th>价格</th>
                <th>图片</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="goods in goodsList">
                <td class = "td-first">{{goods.id}}</td>
                <td>{{goods.product_name}}</td>
                <td>{{goods.product_desc}}</td>
                <td>{{goods.createTime | date:'yyyy-MM-dd HH:mm:ss'}}</td>
                <td>{{goods.inventory_level}}</td>
                <td>{{goods.price}}</td>
                <td><img ng-show="goods.imageURL!=null" ng-src="{{goods.imageURL}}" width="100" onerror="this.style.display='none'"></td>
                <td class="align-right" style = "min-width: 100px;">
                    <a class="btn btn-success btn-xs" ng-click="changeStatus(goods.id,1)"
                       ng-show="goods.status == 0">上架</a>
                    <a class="btn btn-danger btn-xs" ng-click="changeStatus(goods.id,0)"
                       ng-show="goods.status == 1">下架</a>
                    <a class="btn-primary btn-sm" ng-click="updateGoods(goods)">编辑</a>
                </td>
            </tr>
            <tr>
                <td colspan="8" align="center"></td>
            </tr>
            </tbody>
        </table>
    </div>


    <div class="modal fade" id="goods_modal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span
                            aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h5 class="modal-title" id="myModalLabel">{{popupTitle}}</h5>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal" name="backendUserForm">
                        <div class="form-group">
                            <label for="inputLoginId" class="control-label col-xs-2">商品名称:</label>

                            <div class="col-xs-5">
                                <input type="text" class="form-control" ng-model="goods.name" id="goodsName"
                                       required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputUserName" class="control-label col-xs-2">商品描述:</label>

                            <div class="col-xs-5">
                                <textarea type="text" class="form-control" ng-model="goods.desc" id="goodsDesc"
                                       required></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputUserName" class="control-label col-xs-2">库存:</label>

                            <div class="col-xs-5">
                                <input type="number" class="form-control" ng-model="goods.inventory" id="inventory"
                                       required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputUserName" class="control-label col-xs-2">商品价格:</label>

                            <div class="col-xs-5">
                                <input type="text" class="form-control" ng-model="goods.price" id="price"
                                       required>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputUserName" class="control-label col-xs-2">商品图片:</label>

                            <div class="col-xs-5">
                                <input type="file" id="pict" required
                                       onchange="angular.element(this).scope().selectFile(this.files)" accept="image/*">
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button id="saveButton" type="submit" class="btn btn-default"
                                    ng-click="saveAdd(goods)">保存
                            </button>
                            <button id="updateButton" type="submit" class="btn btn-default"
                                    ng-click="saveAdd(goods,'update')">更新
                            </button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>